package com.example.mvc;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.SessionAttributes;

import com.example.entity.Role;
import com.example.service.RoleService;

@Controller
@RequestMapping("/getUsers" )
@SessionAttributes(value={"uname","pwd"})
public class RoleMvc {

	@Autowired
	private RoleService roleService;
	
	private int aw;
	private Role role;
	
	
	@RequestMapping("/addRole")
	public String addUser(@ModelAttribute("role")Role role){
	  
	    aw=roleService.add(role);
	    return Asd(aw,"/queryRole","/error");
	}
			

	
	public String Asd(int aw,String args1,String args2){
		if(aw==1){
			return args1;
		}else{
			return args2;
		}
		
	}
	
	@RequestMapping("/addRole1")
	public String addRole1(){
		
		return "/addRole";	
	}
	
	
}
